from aiohttp.web_routedef import delete
from click import edit
from pywebio import config, pin
from pywebio.output import use_scope, put_text, put_row, put_code, put_column, put_grid, span, put_tabs, put_table, \
    put_link, put_markdown, put_collapse, put_image, toast, PopupSize, popup, put_html, put_buttons
from pywebio.pin import put_input
from pywebio.platform.tornado_http import start_server


def show_msg():
    put_text("You clicked the notification.")


def smjb():
    with use_scope(...) as scope_name:
        put_text("离谱")

    @use_scope(...)
    def app():
        put_text("离谱")

class Friend_Blog():#我的面向对象技术好菜啊~
    def __init__(self,name,link):

        self.name = name
        self.link = link
    def blog(self):
        Text_front = '''
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>卡片效果</title>
		<link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<style type="text/css">
        .card {
         width: 190px;
         height: 70px;
         background: rgb(235, 235, 235,0.4);
         box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 3px 5px -1px, rgba(0, 0, 0, 0.2) 0px -2px 0px inset;
        }
       /* From uiverse.io by @alshahwan */
        button {
          background-color: #fff;
          border: 1px solid skyblue;
          padding: 5px;
          position: relative;
          width: 7.2em;
          height: 2em;
          transition: 0.5s;
          font-size: 17px;
          border-radius: 0.4em;
        }

        button p {
          position: absolute;
          top: 0.4em;
          left: 1.2em;
          margin: 0;
          padding: 0;
          transition: .5s;
          color: skyblue;
        }

        button svg {
          position: absolute;
          top: 0.45em;
          right: 0.5em;
          margin: 0;
          padding: 0;
          opacity: 0;
          transition: 0.5s;
          height: 1em;
          fill: #fff
        }

        button:hover p {
          left: 0.6em;
          color: #fff
        }

        button:hover svg {
          opacity: 1;
        }

        button:hover {
          background-color: skyblue;
        }

		    </style>
        </head>
        '''
        Text_back=f'''<body>
                        <div class="card">
                            <div class="card2">
                                <div style="padding-top: 13px">
                                 <div style="text-align:center"> 
                                <a  href="{self.link}">
                                <button>{self.name}</button>
                                <a/>
                                </div>
                                </div>
                            </div>
                        </div>
                    </body>
                </html>
                '''

        HtmlCode=Text_front+Text_back

        return HtmlCode

#动态读取配置文件
#然后动态传参

config(title="二月的网址导航")  # global configuration

@config(css_style="* { color:red }")  # only works on this application
def app():
    put_text("hello PyWebIO")


def Layout_One():

    Line_1 = Friend_Blog('二月的博客','https://allureluoli.github.io/')
    Line_2 = Friend_Blog("碳酸天剑", "https://blog.tianscar.com/")
    Line_3 = Friend_Blog("HACP","https://allureluoli.github.io/HACP/")
    Line_4 = Friend_Blog("在线聊天室","http://116.204.108.7:8080/")
    Line_5 = Friend_Blog("Nonebot梗","https://nonememe.icu/")
    Line_6 = Friend_Blog("答舟工作室", "https://ansdoship.github.io")
    Line_7 = Friend_Blog("二月的B站", "https://space.bilibili.com/352474844?spm_id_from=333.1007.0.0")
    Line_8 = Friend_Blog("RAT红警社区", "https://www.ratotal.org/")
    Line_9 = Friend_Blog("日想录", "https://blog.nranp.com/")
    Line_10 = Friend_Blog("ydy的博客", "https://daiyunyang.github.io/")
    Line_11 = Friend_Blog("第一个博客", "https://februaryhome.w3spaces.com/")
    Line_12 = Friend_Blog("呆瓜的博客", "https://dgdewangzhan.w3spaces.com/")

    Line_13 = Friend_Blog("菜鸟教程", "https://www.runoob.com/")
    Line_14 = Friend_Blog("Python官方", "https://www.python.org/doc/")
    Line_15 = Friend_Blog("MSDN", "https://msdn.itellyou.cn/")
    Line_16 = Friend_Blog("掌控安全学院", "http://inject2.lab.aqlab.cn/")
    Line_17 = Friend_Blog("cululua", "http://cululua.cn/")
    Line_18 = Friend_Blog("看雪论坛", "https://bbs.kanxue.com/")
    Line_19 = Friend_Blog("CTF-show", "https://ctf.show/")
    Line_20 = Friend_Blog("NSS-CTF", "https://www.ctfer.vip/user/login?redirect=/contest/55/")
    Line_21 = Friend_Blog("攻防世界", "https://adworld.xctf.org.cn/home/index")
    Line_22 = Friend_Blog("安全博客", "https://www.webshell.cc/")
    Line_23 = Friend_Blog("吾爱破解", "https://www.52pojie.cn/")
    Line_24 = Friend_Blog("MDN", "https://developer.mozilla.org/zh-CN/")
    Line_25 = Friend_Blog("Cool Python！", "http://www.coolpython.net/python_primary/python_primary_tutorial.html")
    Line_26 = Friend_Blog("PyWebIo", "https://pywebio.readthedocs.io/en/latest/#")
    Line_27 = Friend_Blog("NoneBot", "https://v2.nonebot.dev/")
    Line_28 = Friend_Blog("RedHat", "https://access.redhat.com/")
    Line_29 = Friend_Blog("UbuntuWiki", "https://wiki.ubuntu.com/")
    Line_30 = Friend_Blog("PyPi", "https://mirrors.tuna.tsinghua.edu.cn/help/pypi/")
    Line_31 = Friend_Blog("W3School", "https://www.w3school.com.cn/")
    Line_32 = Friend_Blog("C语言中文网", "http://c.biancheng.net/")

    Line_33 = Friend_Blog("Dm530p", "https://www.dm530p.net/")
    Line_34 = Friend_Blog("Dmla", "http://www.dmlaa.com/")
    Line_35 = Friend_Blog("Sky岛", "http://www.51skydao.com/")
    Line_36 = Friend_Blog("漫岛动漫", "https://www.mddm.tv/")
    Line_37 = Friend_Blog("CliCli", "http://www.cilicili.cc/")
    Line_38 = Friend_Blog("动漫岛", "http://www.dmd85.com/")
    Line_39 = Friend_Blog("OmOFUN", "https://www.omofun.top/")
    Line_40 = Friend_Blog("DiliDili", "https://dilidili.io/")
    Line_41 = Friend_Blog("动漫花园", "https://www.dongmanhuayuan.com/")
    Line_42 = Friend_Blog("ACE动漫", "https://www.agemys.net/")
    Line_43 = Friend_Blog("风车动漫", "https://www.fengche530.com/")
    Line_44 = Friend_Blog("次元窝", "https://www.i0m0i.com/")
    Line_45 = Friend_Blog("Iliili", "http://www.lililili.cc/")
    Line_46 = Friend_Blog("动漫岛8", "http://www.dmd85.com/")
    Line_47 = Friend_Blog("怡萱动漫", "https://www.yxdmgo.com/")
    Line_48 = Friend_Blog("60Hu", "https://www.60hu.com/")

    SearchButton='''            <div class="search">
                <form class="example" action="https://www.baidu.com/s?">
                    <input type="text" placeholder="小度希望被输入~awa" name="wd">
                    <button type="submit">百度一下 <i class="fa fa-search"></i></button>
                </form>
                <form class="example" action="https://www.google.com/search?">
                    <input type="text" placeholder="QAQ谷歌歌也想要！" name="q">
                    <button type="submit">谷歌一下 <i class="fa fa-search"></i></button>
                </form>
                <!--                百度和Google的搜索框   -->
                '''

    img = open('suxi.png', 'rb').read()




    put_tabs([
        {'title': '首\t页', 'content': [
            put_markdown('---'),
            put_row([

                put_image(r"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202111%2F10%2F20211110220812_f4b9c.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1679574265&t=e45f8b2a339d77718e7bbe2c119c9ba6",title='东海帝皇',width='144px',height='213.2px'),

                put_markdown("\n\n\n\t\n\n\n**欢迎来到二月的网址导航啦！在首页你可以找到二月朋友们的博客，以及各种学习网站和看片网站！awa，这个片是正经的那种哦！**")
                , put_text("\n"),

]           ),
            put_text("\n"),
            put_row([
                put_html(SearchButton)

                ,
                put_image(
                    'https://img0.baidu.com/it/u=3559346466,3393661003&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1677171600&t=8704a6448a5ee3b96328683850ef6b2c',
                    title='俺の爱马',width='160.2px',height='100px'),

            ]),

            put_markdown('---'),
            put_markdown('''
            二月和朋友们
            =
            '''),
            put_row(
                [
                    put_html(Line_1.blog()),
                    put_html(Line_2.blog()),
                    put_html(Line_3.blog()),
                    put_html(Line_4.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_5.blog()),
                    put_html(Line_6.blog()),
                    put_html(Line_7.blog()),
                    put_html(Line_8.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_9.blog()),
                    put_html(Line_10.blog()),
                    put_html(Line_11.blog()),
                    put_html(Line_12.blog())
                ]
            ),
            put_markdown('---'),
            put_markdown('''
            学习网站
            =
            '''),
            put_row(
                [
                    put_html(Line_13.blog()),
                    put_html(Line_14.blog()),
                    put_html(Line_15.blog()),
                    put_html(Line_16.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_17.blog()),
                    put_html(Line_18.blog()),
                    put_html(Line_19.blog()),
                    put_html(Line_20.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_21.blog()),
                    put_html(Line_22.blog()),
                    put_html(Line_23.blog()),
                    put_html(Line_24.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_25.blog()),
                    put_html(Line_26.blog()),
                    put_html(Line_27.blog()),
                    put_html(Line_28.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_29.blog()),
                    put_html(Line_30.blog()),
                    put_html(Line_31.blog()),
                    put_html(Line_32.blog())
                ]
            ),
            put_markdown('---'),
            put_markdown('''
            看片网站（bushi）
            =
            '''),
            put_row(
                [
                    put_html(Line_33.blog()),
                    put_html(Line_34.blog()),
                    put_html(Line_35.blog()),
                    put_html(Line_36.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_37.blog()),
                    put_html(Line_38.blog()),
                    put_html(Line_39.blog()),
                    put_html(Line_40.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_41.blog()),
                    put_html(Line_42.blog()),
                    put_html(Line_43.blog()),
                    put_html(Line_44.blog())
                ]
            ),
            put_text("\n"),
            put_row(
                [
                    put_html(Line_45.blog()),
                    put_html(Line_46.blog()),
                    put_html(Line_47.blog()),
                    put_html(Line_48.blog())
                ]
            ),




        ]},
        {'title': '\t\t\t\t', 'content': [
            put_text('恭喜你发现了隐藏页面，神秘的九宫格！'),
            put_grid(
                [
                    [put_text('守秩善良'), put_text('中立善良'), put_text('混乱善良')],
                    [put_text('守序中立'), put_text('绝对中立'), put_text('混乱中立')],
                    [put_text('守序邪恶'), put_text('中立邪恶'), put_text('混乱邪恶')]

                ], cell_width='100px', cell_height='100px'
            )


        ]},
        {'title': '关\t于', 'content': [
            put_markdown('''
            **呐呐呐这里是二月哦~**
            
            关于本站：
            ====
            
            二月导航，是看到了碳酸天剑导航有感，使用Pywebio编写的一个练手项目。
            QAQ，代码很菜，此项目将开源
            
            关于二月：
            ====
            二月是一个纯纯新的小白哦！在2022年后半年才入坑代码，期间还断断续续的摆烂打了很久的游戏，所以导致至今没有什么技术力QAQ。
            
            关于二月的生平：
            ====
            出身于平民家庭，农村户口，平时大部分时间需要为了应试教育奔波，或者打些零工赚钱。在2020年有幸在游戏圈接触到了一些朋友，便开始长期的在游戏圈中玩耍，在某款RTS小众游戏取得了小小成就。
            此后因为常年上网，对计算机领域包有很多兴趣，便开始学习一些技术。在探索技术的过程中，有幸在Linux运维、Nonebot、Termux、C#，RW-HPS等圈子，认识了一些技术力很强的网友，得到了很多的帮助,二月将铭记于心。
            
            关于开源：
            ====
            前人栽树，后人乘凉。二月对开源此类无私的行为是百分百支持，也因为经常使用开源项目，希望在日后也能为开源社区做出一份贡献。
            
            关于二月的其他信息：
            ====
            是山东人，双子座~男孩子！
            
            关于二月厨的一些角色：
            ====
            御坂美琴、梓喵、清姬、Saber、Miku、洛天依、琪露诺、芙兰朵露、东海帝皇、重炮、目白麦昆、米浴、八六、丛雨、柴郡、莫德雷德、小鸟游六花、春日野穹、TTT喵、有栖nama、长门有希、响、立华奏、艾拉、奇犽·揍敌客、小南、泉此方、亚托莉......
            关于作者的联系方式：QQ：3345483363
            ''')


        ]},
        {'title': '\t\t\t\t', 'content': [
            put_text('我再次声明这个页面不是因为作者太菜去不掉才搞的！'),
            put_image(
                img,
                title='苏茜'),

        ]},
        {'title': '友情链接', 'content': [
            put_markdown('---'),
            put_column([
                put_link('pywebio 官方代码仓', 'https://github.com/wang0618/PyWebIO'),
                put_text('\t'),
                put_link('二月的github', 'https://github.com/allureluoli/'),
                put_text('\t'),
                put_link('此项目的开源地址', 'https://github.com/allureluoli/'),
            ])

        ]},

        {'title': '\t\t\t\t', 'content': None},

        {'title': '学习资料', 'content': [
          put_text('暂时还啥也没写呢嘿嘿！')
        ]}
    ])


    #
    # put_collapse('Collapse title', [
    #     'text',
    #     put_markdown('~~Strikethrough~~'),
    #     put_table([
    #         ['Commodity', 'Price'],
    #         ['Apple', '5.5'],
    #     ])
    # ], open=True)
    #
    # put_collapse('Large text', 'Awesome PyWebIO! ' * 30)
    #
    #
    #
    #
    # with use_scope('A'):
    #     put_text('Text in scope A')
    #     with use_scope('A'):
    #         put_text('嵌套有个卵用吗？')
    #
    # with use_scope('B'):
    #     put_text('Text in scope B')
    #
    # with use_scope('C'):
    #     put_text('Text in scope C')


if __name__ == '__main__':
    # ps:龙卷风这类web使用socket协议默认的使用了0.0.0.0地址?

    start_server(Layout_One,host='0.0.0.0', port=80,cdn=False)#debug=True debug模式不太好用==
